package com.example.demo.generator.codegen.util;

import java.util.Map;

/**
 * Null-safe map helpers mirroring the original generator behaviour.
 */
public final class MapUtils {

    private MapUtils() {
    }

    public static String getString(Map<String, ?> map, String key) {
        if (map == null || !map.containsKey(key)) {
            return "";
        }
        Object value = map.get(key);
        return value != null ? value.toString() : "";
    }

    public static boolean getBoolean(Map<String, ?> map, String key) {
        if (map == null || !map.containsKey(key)) {
            return false;
        }
        Object value = map.get(key);
        if (value instanceof Boolean) {
            return (Boolean) value;
        }
        if (value instanceof String) {
            return Boolean.parseBoolean((String) value);
        }
        return false;
    }
}
